import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_app/util/ToastUtil.dart';

/// *
/// text
/// RichText 一句话或者一段文字里面显示不同样式的文字
class TextWidget extends StatelessWidget {
  TextWidget({
    Key ?key,
    @required this.text,
  }) : super(key: key);
  final String ?text;

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
        appBar: AppBar(
          title: Text(text??""),
        ),
        body: Column(
          children: [
            Text.rich(
              TextSpan(children: [
                TextSpan(text: "Home: "),
                TextSpan(
                  text: "https://flutterchina.club",
                  style: TextStyle(color: Colors.blue),
                ),
              ]),
              style: TextStyle(fontSize: 16.0), // 设置整体大小
            ),
            SizedBox(
              height: 30,
            ),
            RichText(
                text: TextSpan(

                    // style: DefaultTextStyle.of(context).style,
                    children: <InlineSpan>[
                  TextSpan(
                    text: '登录即视为同意',
                    style: TextStyle(color: Color(0xFFfe924a)),
                  ),
                  TextSpan(
                      text: '<提喀服务协议>',
                      style: TextStyle(color: Color(0xFF74cd3d)),
                      recognizer: TapGestureRecognizer()
                        ..onTap = () {
                          ToastUtil.toastShort('服务协议');
                        })
                ])),
            SizedBox(
              height: 30,
            ),
            RichText(
              textAlign: TextAlign.start,
              text: TextSpan(
                  // style: DefaultTextStyle.of(context).style,
                  children: <InlineSpan>[
                    TextSpan(
                        text: 'RichText', style: TextStyle(color: Colors.red)),
                    TextSpan(text: '，', style: TextStyle(color: Colors.black)),
                    TextSpan(
                        text:
                            '一个有态度的程序员,一个有态度的程序员一个有态度的程序员一个有态度的程序员一个有态度的程序员一个有态度的程序员',
                        style: TextStyle(color: Colors.black)),
                    TextSpan(
                        text: '我是两个孤男寡女哪个更',
                        style: TextStyle(color: Colors.black, fontSize: 30)),
                  ]),
            ),
            SizedBox(
              height: 30,
            ),
            Text(
              "左对齐左对齐左对齐左对齐左对齐左对齐左对齐左对齐左对齐左对齐左对齐左对齐左对齐左对齐左对齐",
              textAlign: TextAlign.left,
              maxLines: 1,
              overflow: TextOverflow.ellipsis,
              style: TextStyle(
                  color: Colors.blue,
                  fontSize: 18.0,
                  height: 1.2,
                  fontFamily: "Courier",
                  background: new Paint()..color = Colors.yellow,
                  decoration: TextDecoration.underline,
                  decorationStyle: TextDecorationStyle.dashed),
            ),
            SizedBox(
              height: 30,
            ),
            Text(
              "方法我为无辜如果她退货切换和退货黄金右脚火眼金睛已解决合伙人为会议纪要",
              textAlign: TextAlign.start,
              style: TextStyle(
                color: Colors.blue,
                fontSize: 18.0,
                height: 1.2,
                fontFamily: "Courier",
              ),
            ),
          ],
        ));
  }
}
